<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html >
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<!-- Stylesheets -->
  <link href="<%=basePath%>css/bootstrap.css" rel="stylesheet">
  <!-- Font awesome icon -->
  <link rel="stylesheet" href="<%=basePath%>css/font-awesome.css">
  <!-- Flex slider -->
  <link rel="stylesheet" href="<%=basePath%>css/flexslider.css">
  <!-- prettyPhoto -->
  <link rel="stylesheet" href="<%=basePath%>css/prettyPhoto.css">
  <!-- Main stylesheet -->
  <link href="<%=basePath%>css/style.css" rel="stylesheet">

  <!-- Bootstrap responsive -->
  <link href="<%=basePath%>css/bootstrap-responsive.css" rel="stylesheet">
  
  <!-- HTML5 Support for IE -->
  <!--[if lt IE 9]>
  <script src="js/html5shim.js"></script>
  <![endif]-->

  <!-- Favicon -->
  <link rel="shortcut icon" href="img/favicon/favicon.png">
  
  <script src="<%=basePath%>js/jquery.js"></script>
<script src="<%=basePath%>js/bootstrap.js"></script> <!-- Bootstrap -->
<script src="<%=basePath%>js/filter.js"></script> <!-- Filter JS -->
<script src="<%=basePath%>js/jquery.carouFredSel-6.1.0-packed.js"></script> <!-- CarouFredSel -->
<script src="<%=basePath%>js/jquery.flexslider-min.js"></script> <!-- Flexslider -->
<script src="<%=basePath%>js/jquery.isotope.js"></script> <!-- Isotope -->
<script src="<%=basePath%>js/jquery.prettyPhoto.js"></script> <!-- prettyPhoto -->
<script src="<%=basePath%>js/jquery.tweet.js"></script> <!-- Tweet -->
<script src="<%=basePath%>js/custom.js"></script> <!-- Main js file -->
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript">
	//方法一：if ($("#checkbox-id")get(0).checked) {   // do something}

//方法二：if($('#checkbox-id').is(':checked')) {   // do something}

//方法三：if ($('#checkbox-id').attr('checked')) {   // do something}
		function checkLogin(){
       // var username=$("input[name='username']").val();
       //alert(document.getElementById("username").value);
        var username=$("input#username").val();
        var password = $("input#password").val();
        var check = $("#check").is(":checked");
        //alert(check);
		$.ajax({
				url:"/SpringMVCframe/users/checkLogin",
                cache: true,
                type: "POST",
                data:{username:username,password:password,check:check},
                async: false,
                error: function(request) {
                   alert("登录失败");
                },
                success: function(data) {
                //alert(data.result)
                  if(data.result=="success"){
                  location.href ="/SpringMVCframe/users/getAllUser?username="+username+"&password="+password;
                  }else{
                  alert("登录失败");
                  }
                }
            });
            }
      <%--可以初始化加载调用后台实现  --%>
     <%
     String uname = "";
     String pword = "";
     //获取当前站点的所有Cookie
     Cookie[] cookies = request.getCookies();
     for (int i = 0; i < cookies.length; i++) {//对cookies中的数据进行遍历，找到用户名、密码的数据
         if ("username".equals(cookies[i].getName())) {
            uname = cookies[i].getValue();
         } else if ("password".equals(cookies[i].getName())) {
            pword = cookies[i].getValue();
         }
     }
    %>
   <%--  $(document).ready(function(){  
    
     //alert(<%=uname%>);   
});  --%>
	</script>
  </head>
  
  <body>
    <!-- Navbar starts -->

  <div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
      <div class="container-fluid">
        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </a>
        <div class="nav-collapse collapse">
          <ul class="nav pull-right">
            <li><a href="/SpringMVCframe/zc.jsp">注册</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>

<!-- Navbar ends -->


<!-- Sliding box starts -->
   <div class="slide-box">
      <div class="bor"></div>
      <div class="padd">
        <div class="slide-box-button">
          <i class="icon-chevron-left"></i>
        </div>
        <h5>欢迎</h5>
		
        <hr />

        <div class="social">
          <a href="#"><i class="icon-facebook facebook"></i></a>
          <a href="#"><i class="icon-twitter twitter"></i></a>
          <a href="#"><i class="icon-linkedin linkedin"></i></a>
          <a href="#"><i class="icon-google-plus google-plus"></i></a>
          <a href="#"><i class="icon-pinterest pinterest"></i></a>
        </div>
      
      </div>
    </div>

<!-- Sliding box ends -->    

<!-- Main content starts -->

<div class="content">

  <div class="container-fluid">
    <div class="row-fluid">

      <div class="span12">  

                   <div class="well login-register">
                   
                   <h5>员工登录</h5>
                   <hr />

                    <!-- Login form -->
                    <form class="form-horizontal" id="ajaxFrm" method="post">
                      <!-- Email -->
                      <div class="control-group">
                        <label class="control-label" for="inputEmail">用户名</label>
                        <div class="controls">
                          <input type="text" name="username" id="username"  value="<%=uname%>" placeholder="用户名">
                        </div>
                      </div>
                      <!-- Password -->
                      <div class="control-group">
                        <label class="control-label" for="inputPassword">密码</label>
                        <div class="controls">
                          <input type="password"  name="password" id="password"  value="<%=pword%>" placeholder="密码">
                        </div>
                      </div>
                      <!-- Remember me checkbox and sign in button -->
                      <div class="control-group">
                        <div class="controls">
                          <label class="checkbox">
                            <input type="checkbox" id="check"> 记住我
                          </label>
                          <br>
                        </div>
					  </div>
                <div class="form-actions">
                    <span class="pull-left"><a href="/SpringMVCframe/zc.jsp" class="flip-link btn btn-info" id="to-recover">注册</a></span>
                    <span class="pull-right"><button  type="button" onclick="checkLogin()" class="btn btn-success" >登录</button></span>
                </div>
                      </form>
                   </div>
      </div>

    </div>
  </div>



<div class="clearfix">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
 
</div>

<!-- Main content ends -->
	
<!-- Footer -->
<footer>
            <div class="bor"></div>
            
      
</footer>		

<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span> 

 
  </body>
</html>
